{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "6efba8d2",
   "metadata": {},
   "source": [
    "*日期：2022-11-2 week11（周三)  \n",
    "*课程：python  \n",
    "*记录人：lishengqing  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4496ad46",
   "metadata": {},
   "source": [
    "## 1.元组(tuple)  \n",
    "* 元组的基本概念和形态  \n",
    "* 元组的方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3b7754b1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1800001, 1800002, 1800003) <class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "user_info = 1800001,1800002,1800003\n",
    "print(user_info,type(user_info))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e6fadd3b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1800001, 1800002, 1800003] <class 'list'>\n"
     ]
    }
   ],
   "source": [
    "user_info_list = [1800001,1800002,1800003]\n",
    "print(user_info_list,type(user_info_list))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "169fc23a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1800001\n",
      "(1800001, 1800002)\n"
     ]
    }
   ],
   "source": [
    "# 取值\n",
    "print(user_info[0])\n",
    "# 切片\n",
    "print(user_info[:2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "08bfa5b9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "55723f93",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=11, tm_mday=2, tm_hour=19, tm_min=12, tm_sec=32, tm_wday=2, tm_yday=306, tm_isdst=0)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "5e718468",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1667387572.7559996"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time() #时间戳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "d30ee0f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_info.count(1800001)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a67475d9",
   "metadata": {},
   "source": [
    "## 2.集合\n",
    "\n",
    "> 1.集合的概念和性质  \n",
    ">> 1.集合的唯一性  \n",
    ">> 2.集合的无序性  \n",
    "> 2.集合的方法\n",
    ">> 1.交集：逻辑运算符：setA & setB  , setA.intersection(B)\n",
    ">> 2.并集：逻辑运算符：setA | setB  , setA.union(B)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "37d6e5bc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'pear', 'apple', 'orange', 'banana'} <class 'set'>\n"
     ]
    }
   ],
   "source": [
    "basket ={'apple','orange','apple','pear','orange','banana'}\n",
    "print(basket,type(basket))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "d065a4c9",
   "metadata": {},
   "outputs": [],
   "source": [
    "舞蹈社_user_id = {1800002,1800003,1800111,1800122}\n",
    "合唱团_user_id = {1800003,1800009,1800007,1800111,1801111}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "8d959019",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1800003, 1800111}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "舞蹈社_user_id & 合唱团_user_id"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "00c66924",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1800003, 1800111}"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "舞蹈社_user_id.intersection(合唱团_user_id)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "be531e98",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(舞蹈社_user_id)+len(合唱团_user_id)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "d53600f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(舞蹈社_user_id | 合唱团_user_id)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e701a96e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 思考：如果是列表的话，想要找出重复的项？ 集合的价值\n",
    "舞蹈社_user_id_list =[1800002,1800003,1800111,1800122]\n",
    "合唱团_user_id_list =[1800003,1800009,1800007,1800111,1801111]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d2b5239c",
   "metadata": {},
   "source": [
    "## 3.字典(dict)\n",
    "\n",
    "> 1.字典的概念和性质  \n",
    ">> 1.性质：\n",
    ">>> 1.无序性\n",
    ">>> 2.key是唯一的\n",
    "\n",
    "> 2.字典的创建  \n",
    "```\n",
    ">> 1. key:value\n",
    "网新1班 = {\n",
    "    277:\"船长\",\n",
    "    278:\"盲憎\",\n",
    "    279:\"莫菲特\",\n",
    "    280:\"薇恩\"\n",
    "}\n",
    ">> 2.使用dict()方法创建字典\n",
    "网新2班 = dict(\n",
    "     stu277=\"男枪\"\n",
    "     stu278=\"佛耶格\"\n",
    "     stu279=\"佐伊\"\n",
    "```\n",
    "> 3.字典的方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "c57a031c",
   "metadata": {},
   "outputs": [],
   "source": [
    "wechat = {\n",
    "    \"guduyaogun\":[\"仁川\",\"巴黎\",\"冰岛\"],\n",
    "    \"renchuanren\":[\"剑姬\",\"卡密尔\"]\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "e6a8276c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['仁川', '巴黎', '冰岛']"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wechat[\"guduyaogun\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "b68feada",
   "metadata": {},
   "outputs": [],
   "source": [
    "网新1班 = {\n",
    "    277:\"船长\",\n",
    "    278:\"盲憎\",\n",
    "    279:\"莫菲特\",\n",
    "    280:\"薇恩\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "8972947d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "船长\n"
     ]
    }
   ],
   "source": [
    "print(网新1班[277])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "0f0a37f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "网新2班 = dict(\n",
    "     stu277=\"男枪\",\n",
    "     stu278=\"佛耶格\",\n",
    "     stu279=\"佐伊\"\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
